﻿using System.ComponentModel;
using System.Windows.Controls;
using AdminApp.Resources;

namespace AdminApp.Controls
{
    public partial class SearchControl : UserControl
    {
        public SearchControl()
        {
            InitializeComponent();

            if (DesignerProperties.IsInDesignTool)
            {
                _label.Text = ApplicationStrings.SearchText;
            }

            _searchText.TextChanged += (s, e) =>
                {
                    if (SearchTextChanged != null)
                    {
                        SearchEventArgs args = new SearchEventArgs();
                        args.SearchText = _searchText.Text;
                        SearchTextChanged(this, args);
                    }
                };

            _clear.Click += (s, e) =>
                {
                    _searchText.Text = string.Empty;
                };
        }

        public event SearchEventHandler SearchTextChanged;
    }
}
